Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@saulx/utils
Advanced tools
Saulx utils package
Compare objects
import { stringHash } from '@saulx/utils'
console.log(deepEqual({ a: { b: true } }, { a: { b: true } })) // true
Create a deepcopy of objects
import { deepCopy } from '@saulx/utils'
console.log(deepCopy({ x: true }))
Merge an object into another object, arrays are treated as new values
import { deepMerge } from '@saulx/utils'
const a = { x: { a: { c: true, x: [1, 2] } } }
const b = { y: true }
const c = { x: { a: { b: true, x: ['bla'] } } }
console.log(deepMerge(a, b))
console.log(deepMerge(a, b, c))
/*
Logs
{
x: { a: { b: true, c: true, x: ['bla']}},
y: true
}
*/
Merge an object into another object, arrays are treated as objects
import { deepMergeArrays } from '@saulx/utils'
const a = { x: { a: { c: true, x: [1, 2, 3] } } }
const b = { y: true }
const c = { x: { a: { b: true, x: ['bla'] } } }
console.log(deepMergeArrays(a, b))
console.log(deepMergeArrays(a, b, c))
/*
Logs
{
x: { a: { b: true, c: true, x: ['bla', 2, 3]}},
y: true
}
*/
Checks if a variable is an object and not an array
import { isObject } from '@saulx/utils'
console.log(isObject({ x: true })) // true
console.log(isObject([1, 2, 3])) // false
Timeout in a promise, default is 100ms
import { wait } from '@saulx/utils'
const somethingAsync = async () => {
await wait() // 100ms
console.log('after 100ms')
await wait(1000)
console.log('after 1100ms')
}
somethingAsync()
Sink a read stream into a promise
import { readStream } from '@saulx/utils'
import fs from 'fs'
const aReadStream = fs.createReadStream('somefile')
const myResult = await readStream(aReadStream)
Convert a string to a env variable safe name
import { toEnvVar } from '@saulx/utils'
const x = toEnvVar('@based/bla-bla-bla$_!')
console.log(x) // prints BASED_BLA_BLA_BLA
Pass any async function and queue it based on the arguments, also shares the function execution for the same args
Accepts 5 arguments maximum!
import { queued, wait } from '@saulx/utils'
const myFn = queued(async (a: string) => {
await wait(1000)
return a + '!'
})
// will execute bla first then x
await Promise.all([
myFn('bla'),
myFn('x')
myFn('bla') // bla will be shared
])
import { queued, wait } from '@saulx/utils'
const myFn = queued(async (a: string) => {
await wait(1000)
return a + '!'
}, {
dedup: (a) => {
// choose the value to use for dedup (to share results)
return a
},
concurrency: 10 // max concurrency of 10
})
// will execute all at the same time (scince concurrency is 10)
// will only execute 'bla' once since it has the same arguments used in id
await Promise.all([
myFn('bla'),
myFn('x')
myFn('bla') // bla will be shared
])
Returns a string with the operand/type of the javascrit primitive. Adds 'null' and 'array'.
getType('') // -> "string"
getType('this is a string') // -> "string"
getType(123) // -> "number"
getType(12.3) // -> "number"
getType(-12.3) // -> "number"
getType(-123) // -> "number"
getType(BigInt('1')) // -> "bigint"
getType(true) // -> "boolean"
getType(false) // -> "boolean"
getType(undefined) // -> "undefined"
getType({}) // -> "object"
getType({ a: 'wawa' }) // -> "object"
getType(() => {}) // -> "function"
getType([]) // -> "array"
getType([1, 2, 3]) // -> "array"
getType(null) // -> "null"
Generic structure walker. By default walks objects.
const result = []
await walk(objectToWalk, async (item, info) => {
result.push({
value: item,
name: info.name, // property name
path: info.path, // slash separated path in object
type: info.type // operand type
})
}) // returns void
By configuring the options you can walk any kind of structure
await walk(
objectToWalk, // starting target
itemFn, // function to run for each matched item
options: {
// check types for details
listFn, // function to list each path. Should return a list of items.
itemMatchFn, // function to choose which items to run itemFn on
recureseFn, // function to choose wchich items to recurse on
targetValidationFn, // function to validate starting path
previousPath, // prefix to add to paths
}
})
FAQs
Saulx utils package
The npm package @saulx/utils receives a total of 628 weekly downloads. As such, @saulx/utils popularity was classified as not popular.
We found that @saulx/utils demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.